package com.happy3w.ssp.schoolmatehome.service.auth;

import com.happy3w.ssp.schoolmatehome.entity.User;
import com.happy3w.ssp.schoolmatehome.service.user.UserInfo;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

@Builder
@AllArgsConstructor
@Data
public class SessionInfo {
    private String token;
    private UserInfo userInfo;
    private long expireTime;
    private String jumpCode;

    public static SessionInfo build(User user) {
        JwtToken token = JwtToken.of(user.getId().toString());
        return SessionInfo.builder()
                .token(token.encode())
                .expireTime(token.getExpirationTime())
                .userInfo(UserInfo.from(user))
                .build();
    }
}
